var f = new iot.fs.File('/1.pcm')
f.open(false,true)
iot.audio.record_pcm_stream(function(buffer){
    print("record_pcm_stream callback buffer.len:"+buffer.length)
    f.write(buffer)
},function(result){
    print("record_pcm_stream end:"+result)
    f.close()
    iot.audio.setChannel(2)
    iot.audio.setSpeakerVol(100)
    iot.audio.play_pcm_file('/1.pcm',function(){
        print('play pcm stoped')
        iot.audio.play_stop()
        iot.fs.delFile('/1.pcm')
    })
})

setTimeout(function(){
    print('stop record')
    iot.os.quit()
    iot.audio.record_stop()
},5000)

iot.os.loop()